--
module("UI.Windows.SetTiXianPasswordWin", package.seeall)

 
local UIUtility = require("UI.Utility")
local UIWindow = require("UI.UIWindow").UIWindow
local UIWinMgr = require("UI.UIWinMgr").UIWinMgr

local json = require("cjson")
 
SetTiXianPasswordWin = UIWindow:new()

SetTiXianPasswordWin.name = "SetTiXianPasswordWin"


function SetTiXianPasswordWin:Init()
    local t = self.Container.transform

    self.close_btn = UIUtility.GetChildTransform("close_btn", t, true)
    self.queren_btn = UIUtility.GetChildTransform("queren_btn", t, true)
    self.secondPassword_input=UIUtility.FindContorl("UIInput", "secondPassword_input",t)
    self.secondPassword_input2=UIUtility.FindContorl("UIInput", "secondPassword_input2", t)
    self:BindEvents()

    self.yan1_toggle=UIUtility.FindContorl("UIToggle", "yan1_toggle", t)
    self.yan2_toggle=UIUtility.FindContorl("UIToggle", "yan2_toggle", t)

    self.yan1_toggle.onChange:Clear()
    self.yan1_toggle.onChange:Add(UIHelper.CreateEventDelegate(function()
       
    end, self.yan1_toggle.gameObject))
    
    self.yan2_toggle.onChange:Clear()
    self.yan2_toggle.onChange:Add(UIHelper.CreateEventDelegate(function()
       
    end, self.yan2_toggle.gameObject))
    
end

function SetTiXianPasswordWin:OnShow()

end

function SetTiXianPasswordWin:OnClose()

end

function SetTiXianPasswordWin:BindEvents()
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:CloseWindow(self.name, 1)
    end, self.close_btn.gameObject)

    UIHelper.BindUIEvnet("Click", function()

    
    local loginJson = string.format('{"secondPassword": "%s"}', self.secondPassword_input.value)
 
    require("NetWork.NetHttp").SendPostRequest_token("/byr/user/secondPassword", function(ok, data)
        if ok then
            print("设置提现密码" .. stringify(data))
            UIWinMgr:OpenTextNotice("设置提现密码成功")
            self:Close(1)
            require("UI.Windows.NewGameLoobyWin").NewGameLoobyWin:UpdateUserInfo2()
        else
            UIWinMgr:OpenTextNotice("设置提现密码失败")
        end
    end,loginJson)

    end, self.queren_btn.gameObject)
end
